package com.controller;

import com.entity.Dept;
import com.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/dept")
public class DeptController {
	@Autowired
	private DeptService service;
	// @RequestBody
	// 如果参数是放在请求体中，传入后台的话，那么后台要用@RequestBody才能接收到
	@PostMapping("/add")
	public boolean addDept(@RequestBody Dept dept) {
		return service.addDept(dept);
	}
	@GetMapping("/get/{id}")
	public Dept get(@PathVariable(value = "id") Long id) {
		return service.queryById(id);
	}
	@GetMapping("/list")
	public List<Dept> queryAll() {
		return service.queryAll();
	}
}
